﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization.Json;
using Petra.Gis.Geometry.Support;
using Petra.Gis.ReferenceSystemServices;
using Petra.Gis.ReferenceSystemServices.Transformations;

namespace testSRST
{
  public class testJsonTransform
  {
    public static void testMe()
    {

      MemoryStream m1 = new MemoryStream();
      MemoryStream m2 = new MemoryStream();

      DataContractJsonSerializer j1 = new DataContractJsonSerializer(typeof(BursaWolfGeographicTransform));
      DataContractJsonSerializer j2 = new DataContractJsonSerializer(typeof(Krovak));

      BursaWolfGeographicTransform bt = (BursaWolfGeographicTransform)testBursaWolfTransform.CreateTransform_jtsk_wgs84();
      //Krovak kpt = new Krovak(testSRSJtsk.createJTSK_2065());

      j1.WriteObject(m1, bt);
      //j2.WriteObject(m2, kpt);

      //1. test fromstream
      m1.Position = 0;
      //m2.Position = 0;
      BursaWolfGeographicTransform btOut = (BursaWolfGeographicTransform)j1.ReadObject(m1);
      //Krovak kptOut = (Krovak)j2.ReadObject(m2);

      //2.test from string
      String tstr = System.Text.Encoding.Default.GetString(m1.ToArray());
      m1.Position = 0;
      System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
      byte[] bo = encoding.GetBytes(tstr);
      MemoryStream mOut = new MemoryStream(bo);
      BursaWolfGeographicTransform gcsOut = (BursaWolfGeographicTransform)j1.ReadObject(mOut);

    
    }

  }
}
